# Contributor: Matthias Ahouansou <matthias@ahouansou.cz>
# Maintainer: Matthias Ahouansou <matthias@ahouansou.cz>
pkgname=libunicode
pkgver=0.4.0
pkgrel=0
pkgdesc="Modern C++17 Unicode library"
url="https://contour-terminal.org"
arch="x86_64 aarch64" # 'intrinsics' has not been declared
license="Apache-2.0"
makedepends="
	catch2-3
	cmake
	fmt-dev
	python3
	samurai
	unicode-character-database
"
subpackages="
	$pkgname-dev
	$pkgname-doc
	$pkgname-tools
"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/contour-terminal/libunicode/archive/refs/tags/v$pkgver.tar.gz
	rm-catch2-supression.patch
"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=Release \
		-DBUILD_SHARED_LIBS=ON \
		-DLIBUNICODE_UCD_DIR=/usr/share/unicode \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DLIBUNICODE_TESTING=ON
	cmake --build build
}

check() {
	ctest --test-dir build -C Release --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	install -Dm 644 LICENSE "$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE
}

tools() {
	pkgdesc="$pkgdesc - query tools"

	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/unicode-query -t "$subpkgdir"/usr/bin
}

sha512sums="
48be9f3397f97432ae6a4d6e116fd8e77abf7d085b5dbb74c45828671fd45b6f5ee0e54751cf4aeeec61ab025b6831232cdb9ed1c34e1e7a4ebf84bbe1b4f84b  libunicode-0.4.0.tar.gz
449d88a998259688efec173d36d9bef1171e92f1b2cb3c28b9960417479e1300a849ff9a0fb40453f75375df5d795d2a479bef6eb75a761d66fea9a3f5fb89c6  rm-catch2-supression.patch
"
